#ifndef DDAS_RESULTS_H
#define DDAS_RESULTS_H

#include <matrix\gsl_matrix.h>
#include <sort\gsl_sort_vector.h>
#include <vector\gsl_vector.h>
#include <stdio.h>

#include "lip.h"

///A single result which contains one definition number, one sse and one set of coefficients
struct DDAS_CLIENT_RESULT 
{  
	//WHICH ITERATION THIS RESULT WAS DERIVED FROM
	verylong definition_number;	

	//SUM OF SQUARED ERROR
	double sse;

	//COEFFICIENTS AND RELATED COLUMNS
	gsl_vector* regression_coefficients;
};

///A set of results which contains zero or more DDAS_CLIENT_RESULT structs
struct DDAS_CLIENT_RESULT_SET
{
	int size;

	DDAS_CLIENT_RESULT* result;
};

//STRUCT ALLOCATION
DDAS_CLIENT_RESULT* ddas_client_result_alloc(verylong iteration, gsl_vector* regression_coefficients, double SSE);
DDAS_CLIENT_RESULT_SET* ddas_client_result_set_alloc(int size);
DDAS_CLIENT_RESULT_SET* ddas_client_result_set_calloc(int size);

//STRUCT DEALLOCATION
void ddas_client_result_free(DDAS_CLIENT_RESULT*);
void ddas_client_result_set_free(DDAS_CLIENT_RESULT_SET*);

//STRUCT ACCESSORS
double ddas_get_max_SSE(DDAS_CLIENT_RESULT_SET*);
int ddas_get_index_of_max_SSE(DDAS_CLIENT_RESULT_SET*);
void ddas_replace_worst_result(DDAS_CLIENT_RESULT*);
DDAS_CLIENT_RESULT* ddas_get_ptr_to_worst_result(DDAS_CLIENT_RESULT_SET*);


#endif